SUBSET SUM

Algorithm($S[1 ... m]$, $N$):
  if $N$ == $0$:
    return Yes

  if $N < 0$ or $S$ is empty:
    return No

  for $i$ from $1$ to $m$:
    if Algorithm($S[1 ... m] - S[i]$, $N - S[i]$) returns Yes:
      output $S[i]$
      return Yes

  return No

Algorithm($S[1 ... n]$, $B$)

HAMILTONIAN PATH

Algorithm($G$):
choose any vertex $v \in G.V$ as start
return Hamilton-Visit($G$, $v$)

Hamilton-Visit($G$, $v$):
  if count($V$.visited) == $|V|$:
    return Yes
  for each $u \in Adj[v]$ and $u.visited$ == False:
    $u$.visited $:=$ True
    if Hamilton-Visit($G$, $u$) returns Yes:
      return Yes
  return No

DOMINATING SET

Algorithm($G$, $K$, $S$):
  if Check-Dominating($G$, $K$, $S$):
    return Yes
  for each $v \in (G.V - S)$:
    if Algorithm($G$, $K$, $S \cup \{ v \}$) returns Yes:
      return Yes
  return No

Check-Dominating($G$, $K$, $S$):
  if $|S| > K$:
    return False

  for each $v \in (G.V - S)$:
    flag $:=$ False
    for each $s \in S$:
      if $v \in Adj[s]$:
        flag $:=$ True
        break
    if flag is False:
      return False
  return True

Algorithm($G$, $K$, $\phi$)